package com.css.resoft.p2pmonitor.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.util.Date;

import com.css.resoft.p2pmonitor.util.ReadConifgUtil;


public class DBConnect {
	public static final String name = "com.mysql.jdbc.Driver";
    
	public static final String url = ReadConifgUtil.getInstance().getUrl();
    public static final String user = ReadConifgUtil.getInstance().getUser();
    public static final String password = ReadConifgUtil.getInstance().getPassword();
    
    public Connection conn = null;
    public PreparedStatement pst = null;
    
    public DBConnect(String sql){
    	try {
    		Class.forName(name);
    		conn = DriverManager.getConnection(url,user,password);
    		pst = conn.prepareStatement(sql);
		} catch (Exception e) {
			System.out.println(new Date());
			e.printStackTrace();
		}
    }
    
    public void close(){
    	try{
    		this.pst.close();
    		this.conn.close();
    	}catch(Exception e){
    		System.out.println(new Date());
    		e.printStackTrace();
    	}
    }
    
}
